mybatis调用存储过程
1.mybatis调用oracle存储过程
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="xxxMapper"> <resultMap type="java.util.LinkedHashMap" id="cursorMap"> </resultMap> <select id="getXXX" parameterType="map" useCache="false" statementType="CALLABLE"> <![CDATA[ CALL 存储过程名称( --parameterType="map" 使用map封装参数,直接输入key名称就可以获取到 --mode=IN 输入参数 #{iCompanyid, jdbcType=VARCHAR, mode=IN}, #{iProjid, jdbcType=VARCHAR, mode=IN}, #{iCurPage, jdbcType=DOUBLE, mode=IN}, --当前页 #{iPageSize, jdbcType=DOUBLE, mode=IN}, --条数 --mode=OUT 返回结果 #{iTotalRecords, jdbcType=DOUBLE, mode=OUT}, --总条数 #{iTotalPages, jdbcType=DOUBLE, mode=OUT}, --总页数 --resultMap 映射实体类或用LinkedHashMap接收 #{vCursor, mode=OUT, jdbcType=CURSOR, resultMap=cursorMap}) ]]> </select> </mapper>
2.mybatis调用SQLServer存储过程
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="xxxMapper"> <resultMap id="xxxMap" type="com.xxx.xxxx"> <result column="ProjGUID" property="projGuid" /> <result column="ProjName" property="projName" /> </resultMap> <select id="getXxx" statementType="CALLABLE" parameterType="map" resultMap="xxxMap"> EXEC 存储过程名称 @Year=${iYear}, @Month=${iMonth}, @Days=${iDay}, @TqDate=#{iDate} </select> </mapper>